# Python @property 装饰器详解
'''
@property
def 方法名(self):
    代码块
'''
class Rect:
    def __init__(self, area):
        self.__area = area
    
    @property
    def area(self):
        return self.__area

rect = Rect(30)
# 直接通过方法名来访问 area 方法
print("矩形的面积是：", rect.area)
#rect.area = 90 # AttributeError: can't set attribute
print()

class Rect:
    def __init__(self, area):
        self.__area = area

    @property
    def area(self):
        return self.__area
    
    @area.setter
    def area(self, value):
        self.__area = value
        
    @area.deleter
    def area(self):
        self__area = 0

rect = Rect(30)
print("矩形的面积是：", rect.area)
rect.area = 90
print("修改后的面积：", rect.area)
del rect.area
print("删除后的area值为：", rect.area)
